package com.dto;

import org.springframework.format.annotation.DateTimeFormat;

import java.sql.Date;

public class MeetingDTO {


    private Integer id;

    /**
     * 会议日期
     */
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private Date useDate;

    /**
     * 会议时间
     */
    private Integer useTime;

    /**
     * 开始时间
     */
    private Integer startTime=null;

    /**
     * 结束时间
     */
    private Integer endTime=null;

    /**
     * 会议主题
     */
    private String theme;

    /**
     * 会议室id
     */
    private Integer roomId;

    /**
     * 会议室名称
     */
    private String roomName;

    /**
     * 会议室位置
     */
    private String roomLocation;

    /**
     * 申请状态
     */
    private String status;

    /**
     * 签到状态
     */
    private String checkStatus;

    public MeetingDTO() {
    }

    public MeetingDTO(Integer id, Date useDate, Integer useTime, String theme, Integer roomId, String roomName,
                      String roomLocation, String status, String checkStatus) {
        this.id = id;
        this.useDate = useDate;
        this.useTime = useTime;
        this.theme = theme;
        this.roomId = roomId;
        this.roomName = roomName;
        this.roomLocation = roomLocation;
        this.status = status;
        this.checkStatus = checkStatus;
    }

    @Override
    public String toString() {
        return "MeetingDTO{" +
                "id=" + id +
                ", useDate=" + useDate +
                ", useTime=" + useTime +
                ", theme='" + theme + '\'' +
                ", roomId=" + roomId +
                ", roomName='" + roomName + '\'' +
                ", roomLocation='" + roomLocation + '\'' +
                ", status='" + status + '\'' +
                ", checkStatus='" + checkStatus + '\'' +
                '}';
    }

    public Integer getStartTime() {
        return startTime;
    }

    public void setStartTime(Integer startTime) {
        this.startTime = startTime;
    }

    public Integer getEndTime() {
        return endTime;
    }

    public void setEndTime(Integer endTime) {
        this.endTime = endTime;
    }

    public Date getUseDate() {
        return useDate;
    }

    public void setUseDate(Date useDate) {
        this.useDate = useDate;
    }

    public Integer getUseTime() {
        return useTime;
    }

    public void setUseTime(Integer useTime) {
        this.useTime = useTime;
        this.userTimeConvert();
    }

    public String getTheme() {
        return theme;
    }

    public void setTheme(String theme) {
        this.theme = theme;
    }

    public Integer getRoomId() {
        return roomId;
    }

    public void setRoomId(Integer roomId) {
        this.roomId = roomId;
    }

    public String getRoomName() {
        return roomName;
    }

    public void setRoomName(String roomName) {
        this.roomName = roomName;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCheckStatus() {
        return checkStatus;
    }

    public void setCheckStatus(String checkStatus) {
        this.checkStatus = checkStatus;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getRoomLocation() {
        return roomLocation;
    }

    public void setRoomLocation(String roomLocation) {
        this.roomLocation = roomLocation;
    }

    public void userTimeConvert(){
        int t;
        for(int i = 13;i >= 0; i--){
            t=this.useTime >>> i & 1;
            if (t==1){
                if (this.endTime==null){
                    this.endTime = i+8;
                } else {
                    this.startTime = i+8;
                }
            }
            //System.out.print(t);
        }
        if (this.startTime==null){
            this.startTime=this.endTime;
        }
    }

    public static void main(String[] args) {

        MeetingDTO meetingDTO = new MeetingDTO();
        meetingDTO.setUseTime(12);

        System.out.println(meetingDTO.getStartTime());
        System.out.println(meetingDTO.getEndTime());
    }
}
